home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / siod / siod_v20.lha / siod.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-16  |  2.5 KB  |  107 lines

  1. /* Scheme In One Defun, but in C this time.
  2.  
  3.  *                        COPYRIGHT (c) 1989 BY                             *
  4.  *        PARADIGM ASSOCIATES INCORPORATED, CAMBRIDGE, MASSACHUSETTS.       *
  5.  *        See the source file SLIB.C for more information.                  *
  6.  
  7. */
  8.  
  9. struct obj
  10. {short gc_mark;
  11.  short type;
  12.  union {struct {struct obj * car;
  13.         struct obj * cdr;} cons;
  14.     struct {double data;} flonum;
  15.     struct {char *pname;
  16.         struct obj * vcell;} symbol;
  17.     struct {char *name;
  18.         struct obj * (*f)();} subr;
  19.     struct {struct obj *env;
  20.         struct obj *code;} closure;}
  21.  storage_as;};
  22.  
  23. #define CAR(x) ((*x).storage_as.cons.car)
  24. #define CDR(x) ((*x).storage_as.cons.cdr)
  25. #define PNAME(x) ((*x).storage_as.symbol.pname)
  26. #define VCELL(x) ((*x).storage_as.symbol.vcell)
  27. #define SUBRF(x) (*((*x).storage_as.subr.f))
  28. #define FLONM(x) ((*x).storage_as.flonum.data)
  29.  
  30. #define NIL ((struct obj *) 0)
  31. #define EQ(x,y) ((x) == (y))
  32. #define NEQ(x,y) ((x) != (y))
  33. #define NULLP(x) EQ(x,NIL)
  34. #define NNULLP(x) NEQ(x,NIL)
  35.  
  36. #define TYPE(x) (((x) == NIL) ? 0 : ((*(x)).type))
  37.  
  38. #define TYPEP(x,y) (TYPE(x) == (y))
  39. #define NTYPEP(x,y) (TYPE(x) != (y))
  40.  
  41. #define tc_nil    0
  42. #define tc_cons   1
  43. #define tc_flonum 2
  44. #define tc_symbol 3
  45. #define tc_subr_0 4
  46. #define tc_subr_1 5
  47. #define tc_subr_2 6
  48. #define tc_subr_3 7
  49. #define tc_lsubr  8
  50. #define tc_fsubr  9
  51. #define tc_msubr  10
  52. #define tc_closure 11
  53. #define tc_free_cell 12
  54.  
  55. typedef struct obj* LISP;
  56.  
  57. #define CONSP(x)   TYPEP(x,tc_cons)
  58. #define FLONUMP(x) TYPEP(x,tc_flonum)
  59. #define SYMBOLP(x) TYPEP(x,tc_symbol)
  60.  
  61. #define NCONSP(x)   NTYPEP(x,tc_cons)
  62. #define NFLONUMP(x) NTYPEP(x,tc_flonum)
  63. #define NSYMBOLP(x) NTYPEP(x,tc_symbol)
  64.  
  65. #define TKBUFFERN 256
  66.  
  67. LISP cons(), car(), cdr(), setcar();
  68. LISP setcdr(),consp();
  69.  
  70. LISP symcons(),rintern(), cintern();
  71. LISP cintern_soft();
  72. LISP symbolp();
  73.  
  74. LISP flocons();
  75. LISP plus(),ltimes(),difference();
  76. LISP quotient(), greaterp(), lessp();
  77.  
  78. LISP eq(),eql(),numberp();
  79. LISP assq();
  80.  
  81. LISP lread(),leval(),lprint(),lprin1();
  82.  
  83. LISP subrcons();
  84. LISP closure();
  85.  
  86. LISP leval_define(),leval_lambda(),leval_if();
  87. LISP leval_progn(),leval_setq(),leval_let(),let_macro();
  88. LISP leval_args(),extend_env(),setvar();
  89. LISP leval_quote(),leval_and(),leval_or();
  90. LISP oblistfn(),copy_list();
  91. LISP gc_relocate(),get_newspace(),gc_status();
  92. LISP vload(),load();
  93. LISP leval_tenv(),lerr(),quit(),nullp();
  94. LISP symbol_boundp(),symbol_value();
  95. LISP envlookup(),arglchk(),reverse();
  96.  
  97.  
  98. void gc_protect();
  99.  
  100. long no_interrupt();
  101.  
  102. void init_subr();
  103.  
  104. LISP get_eof_val();
  105. void set_repl_hooks();
  106.  
  107.